home *** CD-ROM | disk | FTP | other *** search
/ Space Simulation Series 1: Lift Off / Liftoff Space Simulation Series Part 1 (ETI Entertainment)(2002).iso / Liftoff / Main2.dxr / 00022_Text_22.txt next >
Text File  |  2002-10-31  |  9KB  |  146 lines

  1. --on getBehaviorDescription me
  2. --  return \
  3. --    "CUSTOM SCROLL BAR" & RETURN & RETURN & \
  4. --    "Create dynamic scrollbars with your own artwork. " & \
  5. --    " Such scrollbars are not Direct-To-Stage, so other sprites can appear over the top of them." & RETURN & RETURN & \
  6. --    "You will need to create four graphic members:" & RETURN & \
  7. --    "+ up arrow" & RETURN & \
  8. --    "+ down arrow" & RETURN & \
  9. --    "+ dragger" & RETURN & \
  10. --    "+ backing bar" & RETURN & RETURN & \
  11. --    "You may wish to use two additional members, to indicate that the arrow buttons have been pressed:" & RETURN & \
  12. --    "+ up arrow (pressed state)" & RETURN & \
  13. --    "+ down arrow (pressed state)" & RETURN & RETURN & \
  14. --    "Place the four standard members on the Stage, and drop this behavior onto each of them. " & \
  15. --    " Choose how the current sprite is to act in the appropriate pop-up menu in the Behavior Parameters dialog." & RETURN & RETURN & \
  16. --    "For each element you can choose whether animations should continue in the background. " & \
  17. --    " This option will tend to slow both the animations and the scrolling process, especially if applied to the arrow buttons." & RETURN & RETURN & \
  18. --    "The various sprites will position themselves automatically to the right of the sprite-to-be-scrolled when the movie runs. " & \
  19. --    " They revert to their original positions when it stops. " & \
  20. --    " To avoid flashes, it would be a good idea to position them by hand in their intended positions." & RETURN & RETURN & \
  21. --    "If you use a border on your field members, the scrollbar will sit outside the border. " & \
  22. --    " Field box shadows are not recommended. " & \
  23. --    " You can always fake external borders and box shadows with shape members (this even gives you a choice of colors)." & RETURN & RETURN & \
  24. --    "To make authoring easier, this behavior will continue to work if you change EITHER the sprite channel OR the member in the chosen channel. " & \
  25. --    " If you change both, the behavior will no longer know what to scroll." & RETURN & RETURN & \
  26. --    "If you do change either the sprite or the member, and then reopen the Behavior Parameters dialog for one of the elements, this will put that behavior out of synch with the others. " & \
  27. --    " Simply reopen and close the Parameters dialogs for each of the other elements. " & \
  28. --    " If you do not do so, you will receive multiple alerts." & RETURN & RETURN & \
  29. --    "This behavior can be used to scroll both editable and non-editable Fields and Text members. " & \
  30. --    " For editable members, however, it does not automatically update the dragger position when the length of the text changes, nor does it make the editable member scroll automatically when the user drags the mouse to create a selection." & RETURN & RETURN & \
  31. --    "PERMITTED MEMBER TYPES:" & RETURN & \
  32. --    "[#animGif, #bitmap, #filmLoop, #flash, #movie, #picture, #shape]" & RETURN & RETURN & \
  33. --    "PARAMETERS:" & RETURN & \
  34. --    "* Current sprite acts as (up|down arrow | dragger | bar)" & RETURN & \
  35. --    "* Scroll the member of <sprite>: <the member of sprite>" & RETURN & \
  36. --  "* Standard member (this should not need to be set)" & RETURN & \
  37. --    "* Member to display when arrow buttons are pressed" & RETURN & \
  38. --    "* Allow animations to continue" & RETURN & RETURN & \
  39. --    "PUBLIC METHODS" & RETURN & \
  40. --    "=> Scroll the text/field member to a given position" & RETURN & \
  41. --    "=> Swap the text/field  member to be scrolled" & RETURN & \
  42. --    "=> Get the behavior reference"
  43. --end getBehaviorDescription
  44.  
  45.  
  46. -- NOTES FOR DEVELOPERS
  47.  
  48. -- This is the most complex behavior I have written for the Behavior Library.
  49. -- I have included in one script all the handlers necessary to deal with each
  50. -- of the four elements of a scroll bar.
  51. -- 
  52. -- In practice, this one script works as four separate behaviors.  Each element
  53. -- is identified by its myScrollRole (upArrow, downArrow, dragger or bar).  The
  54. -- behavior acts differently for each myScrollRole.  Many handlers are divided
  55. -- into section by a "case myScrollRole of" statement.
  56.  
  57. -- INSTALLATION
  58. -- Initializing the 4 behaviors cannot be done all at once on beginSprite
  59. -- because the behaviors on the other sprites may not exist.  To get round
  60. -- this, I set a myState property to 0 in the StartInstallation handler
  61. -- (on beginSprite).  The first prepareFrame (which is sent once all behaviors
  62. -- in the current frame have been instanciated) sees that "myState + 0 = 0"
  63. -- (or FALSE) and calls the FinishInstallation handler.
  64.  
  65. -- Why "myState + 0"?  Because once the installation is finished, myState is
  66. -- set to #done.  This is a symbol.  A symbol is simply an integer with a
  67. -- special tag.  Adding zero to a symbol gives you access to the integer
  68. -- itself.  Later, when the prepareFrame handler encounters "#done + 0" it
  69. -- evaluates this as a positive integer (or TRUE) and doesn't botherd to
  70. -- reinstall the elements.
  71.  
  72. -- This technique is excessively fast: it slows down the following
  73. -- prepareFrames by something in the order of a millionth of a second.
  74.  
  75. -- Installation itself is a three step-process.
  76.  
  77. -- First: the behavior has to check if the sprite and member that it is to
  78. -- scroll do actually appear where it expects to find them.  The
  79. -- ourScrolledElement property returned by the getPropertyDescriptionList
  80. -- handler is a double-barreled affair: "sprite X:field(member Y of castLib Z)".
  81. -- If sprite X contains a Field or Text member, the behavior assumes that this
  82. -- is the right one, and adopts it as myScrolledMember.  If not, it sets out to
  83. -- look for (member Y of castLib Z), via the FindSprite handler.  If it finds
  84. -- this member in one of the sprites in the frame, then it adopts the new
  85. -- sprite as myScrolledSprite.  If not, it warns the author (4 times, once for
  86. -- each behavior).
  87.  
  88. -- Second: the current behavior has to check if all the others are present.
  89. -- The Initialize handler has already prepared a list of all behaviors which
  90. -- treat the same sprite and/or member: ourControlList.  The CheckControl
  91. -- handler ensures that this list contains one behavior for each control
  92. -- element... and only one.
  93.  
  94. -- Third: the sprite to which the behavior is attached has to be placed
  95. -- correctly beside the sprite it is to scroll.  This is most complex for the
  96. -- Dragger sprite, since it must be placed in accordance with the current
  97. -- scrollTop of myScrolledMember.
  98.  
  99. -- The scrolling itself is always carried out by the behavior attached to the
  100. -- dragger.  The Move and MoveBar handlers (which deal with clicks on the arrow
  101. -- buttons and on the backing bar) end with a...
  102. -- 
  103. --   call (#SetDraggerShift, ourControlList.dragger)
  104. -- 
  105. -- ... command.  The bar behavior must in addition ask the dragger where it now
  106. -- is, using "call (#GetDraggerData, ourControlList.dragger)", so as to update its
  107. -- myActiveZone.
  108.  
  109. -- EXTERNAL LINGO CALLS
  110.  
  111. -- * CustomScrollbar_SetScroll me, theScroll
  112.  
  113. -- If you use standard Lingo to set the scrollTop of myScrolledMember at
  114. -- runtime,  the dragger position will not update until the scroll bar is next
  115. -- used.  Use this call to tell the dragger to do all the work for you
  116.  
  117. -- * CustomScrollbar_SwapMember me, newMember, currentMemberOrSprite
  118.  
  119. -- If you use standard Lingo to swap the member of myScrolledSprite at runtime,
  120. -- the behaviors will continually happily to scroll the member which is now
  121. -- off-stage.  Use this call to tell one of the behaviors do the swapping for
  122. -- you.
  123.  
  124. -- * CustomScrollbar_GetReference me, memberOrSprite, controlOrList
  125.  
  126. -- Using sendAllSprites with one of the above messages will ensure that the
  127. -- job gets done... four times, once by each behavior that makes up the
  128. -- scroll bar.  If you call one of the behaviors directly, the command will be
  129. -- executed just once.  But first you must get an object reference to the
  130. -- behavior in question.  The following syntax is the simplest:
  131. -- 
  132. --   scrollRef = sendAllSprites (#CustomScrollbar_GetReference, sprite X)
  133. -- 
  134. -- This will give you a reference to the behavior on the highest sprite which
  135. -- controls the scrolling of sprite X.
  136.  
  137. -- More details on using these external calls are given in the handlers
  138. -- themselves.
  139.  
  140.  
  141.  
  142. -- HISTORY --
  143.  
  144. -- 27  October 1998: written for the D7 Behaviors Palette by James Newton
  145. -- 24 November 1998: vector shapes abandoned as permitted members
  146. -- 12 january 2000: Added isOKToAttach and removed unneeded error checking.